Enable Python workflow with BytePairTokenizer and StartEndPacker#2628
Enable Python workflow with BytePairTokenizer and StartEndPacker#2628james77777778 wants to merge 5 commits intokeras-team:masterfrom
BytePairTokenizer and StartEndPacker#2628Conversation
…dPacker` to `StartEndPacker`.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the flexibility and usability of key preprocessing layers, Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly improves the BytePairTokenizer and StartEndPacker layers by enabling Python workflow functionality, alongside the existing TensorFlow-compatible workflow. The refactoring of call methods into _call_tf and _call_python for StartEndPacker and the integration of the tokenizers library for BytePairTokenizer are well-executed. The extensive test updates, including parameterization for _allow_python_workflow, demonstrate thoroughness. The removal of v2 specific files for these components indicates a successful consolidation. However, there is an inconsistency in how invalid merge rules are handled between the Python and TensorFlow paths in BytePairTokenizer.
Note: Security Review did not run due to the size of the PR.
Description of the change
On second thought, I think merging the Python workflow functionality into the original
BytePairTokenizerandStartEndPackerlayers will provide a more seamless UX. Users will benefit from a default Python workflow while maintaining a smooth experience when using these layers withintf.data.Extensive tests have been added for these core modules:
keras_hub/src/tokenizers/byte_tokenizer_test.pykeras_hub/src/layers/preprocessing/start_end_packer_test.pyThe diff is quite large due to updated tests. I found that all
BytePairTokenizertests were WRONG: BPE requires all elements inmergesto be present invocabulary.Our
tfandtf-textimplementation is more permissive than widely adopted libraries liketokenizers.Key updates for reviewers:
_allow_python_workflowtoPreprocessingLayerto indicate whether a layer supports Python workflowReference
Colab Notebook
https://colab.research.google.com/drive/1YDHUwdjwgO0BGuelYLTRNvVB1Ulc1K7X?usp=sharing
Checklist